package com.hxx.h

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import com.hxx.widget.bar.BarAppCometActivity
import com.hxx.widget.sheet.*
import com.hxx.widget.switch.SwitchButton

class MainActivity : BarAppCometActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
    private fun showDialog() {
        val dialog = BottomSheetDialog(this, BottomSheetDialog.Option().apply {
            title = "标题"
            confirmShow = true
            cancelShow = true
        })
        val component = object : Arrow() {
            override fun applyHotView(view: View, item: BottomSheetItem) {
                view.setOnClickListener {
                    Log.i("点击的", "applyHotView: ${item.title}")
                }
            }
        }
        val switchComponent = object : Switch() {
            override fun applyHotView(view: SwitchButton, item: BottomSheetItem) {
                view.setCheckedState(true)
                view.onCheckStateChangedListener = {
                    Log.i("单选", "applyHotView: $it")
                }
            }
        }
        val nullComponent = object : Null() {
            override fun applyHotView(view: View, item: BottomSheetItem) {
                view.setOnClickListener {
                    Log.i("默认", "applyHotView: $it")
                }
            }
        }
        dialog.show(
            BottomSheetItem("箭头", R.drawable.widget_ic_plus, component),
            BottomSheetItem("switch", R.drawable.widget_ic_plus, switchComponent),
            BottomSheetItem("默认", R.drawable.widget_ic_plus, nullComponent)
        )
    }
}
